package com.xxx.video.guide.activitys;

import android.os.Bundle;

import com.xxx.video.R;
import com.xxx.video.commen.activitys.BaseActivity;
import com.xxx.video.commen.configs.UserManager;
import com.xxx.video.guide.presenters.ISplashView;
import com.xxx.video.guide.presenters.SplashPresenter;
import com.xxx.video.guide.views.UserAgencyTipDialog;
import com.xxx.video.main.activitys.MainActivity;

public class SplashActivity extends BaseActivity<SplashPresenter> implements ISplashView, UserAgencyTipDialog.OnUserAgencyDialogButtonClickListener {
    @Override
    protected SplashPresenter createPresenter() {
        return new SplashPresenter(this, this);
    }

    @Override
    public int getContentLayout() {
        return R.layout.activity_splash;
    }

    @Override
    public void initData(Bundle extras) {
        showLayoutStatus(1);
        if (!UserManager.getInstance().getIsAgreeAgency()) {
            showUserAgencyDialog();
        } else {
            startMainActivity();
        }
    }

    @Override
    public void showRootLayoutStatus(int status) {
        showLayoutStatus(status);
    }

    @Override
    public void showUserAgencyDialog() {
        UserAgencyTipDialog userAgencyTipDialog = new UserAgencyTipDialog(this);
        userAgencyTipDialog.setOnUserAgencyDialogButtonClickListener(this);
        if (!userAgencyTipDialog.isShowing()) {
            userAgencyTipDialog.show();
        }
    }

    @Override
    public void startMainActivity() {
        intent2Activity(MainActivity.class);
        finish();
    }

    @Override
    public void onUserAgencyDialogButtonClick(int type) {
        switch (type) {
            case UserAgencyTipDialog.USER_AGENCY_CLICK_TYPE_FINISH_APP:
                finish();
                break;
            case UserAgencyTipDialog.USER_AGENCY_CLICK_TYPE_START_MAIN_ACTIVITY:
                UserManager.getInstance().setIsAgreeAgency(true);
                startMainActivity();
                break;
            case UserAgencyTipDialog.USER_AGENCY_CLICK_TYPE_START_USER_AGREEMENT:
                break;
            case UserAgencyTipDialog.USER_AGENCY_CLICK_TYPE_start_user_privacy_policy:
                break;
            default:
                break;
        }
    }
}
